package com.glsc.ngateway.common.base.converter.platform;

import com.alibaba.excel.util.CollectionUtils;
import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.flow.FlowFormSystemNameModify;
import com.glsc.ngateway.common.base.domainmapper.FlowFormSystemNameModifyMapper;
import com.glsc.ngateway.common.api.flowable.dto.task.formData.system.domainDto.FlowFormSystemNameModifyDto;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @author zhengyr
 */
public class FlowFormSystemNameModifyConverter extends AbstractFlowFormDataConverter {

    public static FlowFormSystemNameModifyDto do2Dto(FlowFormSystemNameModify domain) {
        if(Objects.isNull(domain)){
            return null;
        }
        FlowFormSystemNameModifyDto dto = FlowFormSystemNameModifyMapper.INSTANCE.domain2dto(domain);
        dto.setAppendicesFileList(converter2FileList(domain.getAppendicesFileIdList()));
        return dto;
    }

    public static List<FlowFormSystemNameModifyDto> do2Dto(List<FlowFormSystemNameModify> domainList) {
        return CollectionUtils.isEmpty(domainList) ? java.util.Collections.emptyList() : domainList.stream().map(FlowFormSystemNameModifyConverter::do2Dto).collect(Collectors.toList());
    }

    public static FlowFormSystemNameModify dto2Do(FlowFormSystemNameModifyDto dto) {
        if(Objects.isNull(dto)){
            return null;
        }

        FlowFormSystemNameModify apply = FlowFormSystemNameModifyMapper.INSTANCE.dto2domain(dto);
        apply.setAppendicesFileIdList(converter2FileIdList(dto.getAppendicesFileList()));

        return apply;
    }

    public static List<FlowFormSystemNameModify> dto2Do(List<FlowFormSystemNameModifyDto> dtoList) {
        return CollectionUtils.isEmpty(dtoList) ? java.util.Collections.emptyList() : dtoList.stream().map(FlowFormSystemNameModifyConverter::dto2Do).collect(Collectors.toList());
    }
}
